home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Messaging / OSL / OSLDspse.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-22  |  5.6 KB  |  225 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        OSLDspse.c (Orignal name: OSLDispose.c)
  3.  
  4.     Contains:    
  5.  
  6.     Owned by:    Nick Pilch
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <4>     6/23/95    NP        125932: Call system handlers if app
  13.                                     handlers fail.
  14.          <3>     1/12/95    jpa        Don't use obsolete Toolbox names [1211211]
  15.          <2>     8/19/94    NP        1181622: Ownership fix.
  16.          <7>      5/2/94    eeh        bug #1160654: various PPC native changes
  17.          <6>    10/18/93    NP        Added DisposeTokenProc callback support for
  18.                                     OpenDoc.
  19.          <5>     8/16/93    NP        Adjusted for latest OSL proposal.
  20.          <4>     7/29/93    NP        Added missing return value for
  21.                                     OLSDisposeToken.
  22.          <3>     7/28/93    NP        Mods for new token type, OSLToken.
  23.          <2>     7/21/93    NP        Fixed #includes.
  24.          <1>     7/21/93    NP        first checked in
  25.  
  26.     To Do:
  27.     In Progress:
  28. */
  29.  
  30. /*                                            
  31.     ©Apple Computer, Inc.  1992         
  32.           All Rights Reserved.                
  33.     Author: Eric House
  34.                                             */
  35. #ifndef __MIXEDMODE__
  36. #include <MixedMode.h>
  37. #endif
  38.  
  39. #ifndef _OSLPRIV_
  40. #include "OSLPriv.h"
  41. #endif
  42.  
  43. #pragma segment AEObjSuppt
  44.  
  45. // ———————————————————————— InternalDisposeToken ————————————————————————
  46.  
  47.         // disposes of OSLTokens without calling app's dispose token routine
  48.  
  49. pascal OSErr
  50. InternalDisposeToken( OSLToken* token )
  51. {
  52.     return AEDisposeDesc(token);
  53. }
  54.  
  55. // ———————————————————————— DisposeCompEvnt ————————————————————————
  56.  
  57.         // disposes of CompEvnt Handles
  58.  
  59. static void
  60. DisposeCompEvnt( CompareEvent c )
  61. {
  62.     if ( c != NULL )
  63.     {
  64.         IgnoreOSErr( AEDisposeDesc( &(*c)->theCompEvtInput )) ;
  65.         IgnoreOSErr( AEDisposeDesc( &(*c)->eventWParams ) ) ;
  66.         DisposeHandle((Handle)c ) ;
  67.     }
  68. } // DisposeCompEvnt
  69.  
  70.     /*———————————————————————— DisposeCompare ————————————————————————*/
  71.  
  72.         /*disposes of comparison Handles*/
  73. void
  74. DisposeCompare( Comparison c )
  75. {
  76.     if ( c != NULL )
  77.     {
  78.         IgnoreOSErr( AEDisposeDesc( &(*c)->theCompInput )) ;
  79.         DisposeObj( (*c)->obj1 ) ;
  80.         DisposeObj( (*c)->obj2 );
  81.         DisposeHandle((Handle)c ) ;
  82.     }
  83. } // DisposeCompare
  84.  
  85.     /*———————————————————————— DisposeLogical ————————————————————————*/
  86.  
  87. void
  88. DisposeLogical( Logical l )
  89. {
  90.     if ( l != NULL )
  91.     {
  92.         IgnoreOSErr( AEDisposeDesc( &(*l)->theLogicalInput ) ) ;
  93.         DisposeTerm( (*l)->firstTerm ) ;
  94.         DisposeHandle( (Handle)l ) ;
  95.     }
  96.  
  97.         
  98.     /*———————————————————————— DisposeTerm ————————————————————————*/
  99.  
  100. void
  101. DisposeTerm( Term t )
  102. /*disposes of test term Handles*/
  103.  
  104. {
  105.     if ( t != NULL )
  106.     {
  107.         DisposeTerm( (*t)->next ) ;
  108.         IgnoreOSErr( AEDisposeDesc( &(*t)->theTermInput ) ) ;
  109.  
  110.         switch ( (*t)->ttype )
  111.         {
  112.             case kCompare :
  113.                 DisposeCompare( (Comparison)(*t)->u.compar ) ;
  114.                 break ;
  115.             case kCompareEvt :
  116.                 DisposeCompEvnt( (CompareEvent)(*t)->u.cEvt ) ;
  117.                 break ;
  118.             case kLogical :
  119.                 DisposeLogical( (Logical)(*t)->u.log ) ;
  120.                 break ;
  121.         }
  122.             
  123.         DisposeHandle( (Handle)t ) ;
  124.     }
  125. } /*DisposeTerm*/
  126.  
  127.  
  128.     /*———————————————————————— DisposeWhose ————————————————————————*/
  129.  
  130. void
  131. DisposeWhose( Whose w )
  132.     /*disposes of Whose Handles*/
  133.     if ( w != NULL )
  134.     {
  135.         DisposeTerm( (*w)->theTerm ) ;
  136.         IgnoreOSErr( AEDisposeDesc( &(*w)->theWhoseInput )) ;
  137.         DisposeHandle( (Handle)w ) ;
  138.         /* don't dispose of whose value, it is an end product! */
  139.     }
  140. } /*DisposeWhose*/
  141.  
  142.  
  143.     /*———————————————————————— DisposeObj ————————————————————————*/
  144.  
  145. void
  146. DisposeObj( Object o )
  147. /*disposes of object records in comparison Handles*/
  148.  
  149. {
  150.     if ( o != NULL )
  151.     {
  152.         HLock( (Handle) o ) ;            /* AEDisposeDesc may write back, so don't let it move */
  153. //        WITH o** DO                        /* ...and as long as we're locking... */
  154.         {
  155.             ObjRecordPtr op = *o ;
  156.             DisposeObj( op->objContainer );
  157.             DisposeWhose( (Whose)op->objTheWhose );
  158.             IgnoreOSErr( AEDisposeDesc( &op->objSelectionData )) ;
  159.             IgnoreOSErr( AEDisposeDesc( &op->theObjInput )) ;
  160.  
  161.             /* objValue is sometimes a token, sometimes not.  eg in the case where
  162.               we are comparing a word with text obj2 has the text as its value. */
  163.  
  164.             if ( op->objRedo )
  165.             {
  166.             if ( !op->valIsExmn )
  167.                 IgnoreOSErr( iAEDisposeToken( &op->objValue ) ) ;
  168.             }
  169.             else if ( ! (op->objClass == typeToken) )            /* test added 4/4 as part of ccnt conversion */
  170. //                IgnoreOSErr( AEDisposeDesc( &op->objValue ) ) ;
  171.                 IgnoreOSErr( OSLDisposeToken( &op->objValue ) ) ;
  172.  
  173.         }
  174.         DisposeHandle( (Handle) o ) ;
  175.     }
  176. } /*DisposeObj*/
  177.  
  178.  
  179. ////////////////////////////////////////////////////////////////////////////////
  180. // iAEDisposeToken
  181. // if the app calls disposeToken and there is no such proc, it should return
  182. // an error -- NoSuchProcErr toka.  But if I call it and there is none,
  183. // AEDisposeDesc should be called instead.  Best solution for now is not
  184. // to treat the absence of a proc as an error; just default to disposeDesc().
  185. ////////////////////////////////////////////////////////////////////////////////
  186.  
  187. static OSErr
  188. TryOneProc( GlobalRecHandle aGlobalRef, OSLToken *theDesc )
  189. {
  190.     OSErr err = errAENotASpecialFunction ;        // with "|" below, fixes LLD-UPG-8 }
  191.     if ( aGlobalRef != NULL )
  192.     {
  193.         OSLDisposeTokenUPP aProcPtr = (*aGlobalRef)->diposeTokenProcPtr ;
  194.         if ( aProcPtr != NULL ) 
  195.             err = CallOSLDisposeTokenProc(aProcPtr, theDesc);
  196.     }
  197.     return err ;
  198. }
  199.  
  200.  
  201. pascal OSErr
  202. iAEDisposeToken( OSLToken *theDesc ) // Directly from Ed's stuff; not a word changed }
  203. {
  204.     OSErr err ;
  205.         
  206.     if ( theDesc->descriptorType != typeNull )
  207.     {
  208.         err = NewCallDisposeToken(theDesc);
  209. //        err = TryOneProc( GetGlobalRef(), theDesc ) ;
  210.         if ((err == errAEEventNotHandled)
  211.                 || (err == errAENotASpecialFunction) ) 
  212.             err = TryOneProc( GetSysGlobal(), theDesc ) ; // not there? then try the system-wide one
  213.         if (( err == errAEEventNotHandled)
  214.                 || (err == errAENotASpecialFunction) ) 
  215.             err = AEDisposeDesc( theDesc ) ;        // <eeh> here is err where i=166 from command-2
  216.     }
  217.     else
  218.         err = noErr ;
  219.  
  220.     return err ;
  221. } // iAEDisposeToken
  222.  
  223.